package com.bsoft.servicetest;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.support.annotation.Nullable;

import com.socks.library.KLog;

/**
 * Created by 泅渡者
 * Created on 2017/9/20.
 */

public class MyService extends Service {


    MyBinder myBinder = new MyBinder();

    @Override
    public void onCreate() {
        super.onCreate();
        KLog.d("onCreate() 被执行");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        KLog.d("onStartCommand() 被执行");
//        new Thread(){
//            @Override
//            public void run() {
//                super.run();
//                while (true) {
//                    try {
//                        Thread.sleep(10000);// 线程暂停10秒，单位毫秒
//                        KLog.e("老子又来了");
//                    } catch (InterruptedException e) {
//                        // TODO Auto-generated catch block
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }.start();
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        KLog.d("onDestroy() 被执行");
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        KLog.d("onBind() 被执行");
        return myBinder;
    }

    class MyBinder extends Binder{

        public void Download(){

            KLog.d("Download() 下载任务被执行");
        }

    }
}
